﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Drawing;
using DevExpress.Web.ASPxTreeList;


public partial class WebUserControl_ControlBaoCaoDuyetDSThamGiaHoiNghiKinhDoanhToanQuoc : System.Web.UI.UserControl
{
    ClassExecute.ClassExecute dt;
    static DataTable db;
    string str = BCDataCenter.Configuration.CurrentConnectionString;
    static string error = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindDrop();
        }
        else
        {
            try
            {
                ASPxTreeList1.DataSource = db;
                ASPxTreeList1.DataBind();
                ASPxTreeList1.ExpandAll();
            }
            catch
            {
                return;
            }
        }
    }
    void BindDrop()
    { 
        dt = new ClassExecute.ClassExecute();
        DataTable dbUser = dt.Get_Data_DataTable(str, ref error, "ls_getMTYMonthList", CommandType.StoredProcedure);
        DropThang.DataSource = dbUser;
        DropThang.DataTextField = "mText";
        DropThang.DataValueField = "mVal";
        DropThang.DataBind();
    }
    protected void ASPxTreeList1_HtmlRowPrepared(object sender, DevExpress.Web.ASPxTreeList.TreeListHtmlRowEventArgs e)
    {
        if (e.RowKind == TreeListRowKind.Data)
        {
            if (e.GetValue("NguoiMoi").ToString() == "1")
            {
                e.Row.BackColor = Color.Aqua;
            }
        }
    }
    protected void btXem_Click(object sender, EventArgs e)
    {
        BindData();
    }
    protected void btPrint_Click(object sender, EventArgs e)
    {
        try
        {
            ASPxTreeList1.ExpandAll();
            ASPxTreeListExporter1.WriteXlsToResponse("DSThamGiaHoiNghiKinhDoanhToanQuoc.xls");
           
        }
        catch 
        {
            return;
        }
    }
    void BindData()
    {
        try
        {
            
                dt = new ClassExecute.ClassExecute();
                db = dt.Get_Data_DataTable(str, ref error, "ls_getDanhSachBUMVaTuyenMoi", CommandType.StoredProcedure,
                    new SqlParameter("@userName", Session["username"].ToString()),
                    new SqlParameter("@selYyyyMM", DropThang.SelectedValue.ToString()));
                ASPxTreeList1.DataSource = db;
                ASPxTreeList1.DataBind();
                ASPxTreeList1.ExpandAll();
            
        }
        catch (Exception ex)
        {
            BCDataCenter.ClassWriteLogErr obj = new BCDataCenter.ClassWriteLogErr();
            string method = System.Reflection.MethodBase.GetCurrentMethod().Name;
            obj.ErrorLog(ex.Message + error, method);
        }
    }
}
